package cn.lanca.gof0_5._05builder.case1.director;

import com.example.demo.gof0_5._05builder.case1.builder.Builder;
import com.example.demo.gof0_5._05builder.case1.product.Product;

/**
 * 指挥者：调用建造者中的方法完成复杂对象的创建。
 *
 * @author meihongliang
 * @since 2020/8/7 16:55
 */
public class Director {
    private Builder builder;

    /**
     * 指挥者的构造器
     *
     * @param builder
     */
    public Director(Builder builder) {
        this.builder = builder;
    }

    /**
     * 产品构建与组装方法
     *
     * @return Product
     */
    public Product construct() {
        builder.buildPartA();
        builder.buildPartB();
        builder.buildPartC();
        return builder.getResult();
    }
}
